package saxion.speelveld.spaceengineer.controller;

import java.util.ArrayList;

import saxion.speelveld.spaceengineer.R;
import saxion.speelveld.spaceengineer.model.TradeDeal;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

public class simpleSpinnerDealAdapter extends ArrayAdapter<TradeDeal> implements SpinnerAdapter
{

	Context context;

	ArrayList<TradeDeal> tradeableDeals;

	public simpleSpinnerDealAdapter(Context context, ArrayList<TradeDeal> tradeableDeals2)
	{
		super(context, R.layout.trade_deal_view_item, tradeableDeals2);
		this.context = context;
		this.tradeableDeals = tradeableDeals2;

	}

	@Override
	public View getDropDownView(int position, View convertView, ViewGroup parent)
	{
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		convertView = inflater.inflate(R.layout.trade_deal_view_item, parent, false);
		((TextView) convertView.findViewById(R.id.tv_deal_to_trade)).setText(tradeableDeals.get(position).toString());

		return convertView;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent)
	{
		LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		convertView = inflater.inflate(R.layout.trade_deal_view_item, parent, false);
		((TextView) convertView.findViewById(R.id.tv_deal_to_trade)).setText(tradeableDeals.get(position).toString());

		return convertView;

	}

}
